import {Service, action} from "adajs";
import Input from "../../../../controls/form/input";
import Username from "../../../../controls/form/username";
import HosSelect from "./../../../../controls/form/hosselect";
import HostList from "./../../../../controls/lists/hospital";

class LodgeService extends Service {
    defaultData() {
        return {
            title: "设置",
            form: {
                fields: [
                    {type: Username, name: "ltzid", label: "姓名", inputType: "text", required: true},
                    {type: Input, name: "yiyuan", label: "医院名称", inputType: "text", required: true},
                    {type: Input, name: "ksbc", label: "科室病床", inputType: "text", required: true},
                    {type: Input, name: "rysj", label: "入院时间", inputType: "date", required: true},
                    {type: Input, name: "bq", label: "病情", inputType: "text", required: true},
                    {type: Input, name: "phr", label: "陪护人", inputType: "text", required: true},
                    {type: Input, name: "phrdh", label: "陪护人电话", inputType: "text", required: true},
                    {type: HosSelect, name: "sfcy", label: "是否出院", options: []}
                ],
                btns: []
            },
            ltzname: "",
            list: {
                url: "/api/admin/lgb/hospitalization/queryPage",
                parameter: {
                    ltzid: ""
                },
                type: HostList
            },
            btns: [{action: "check", icon: ":for-check_circle"}]
        };
    }

    onupdate(current, data) {
        Object.assign(current, data);
    }

    @action("setList")
    setList(current, data) {
        current.ltzname = data.userRealname;
        current.list.parameter.ltzid = data.id;
    }
}

export default LodgeService;